package com.xwli.springcloud.controller;

import com.xwli.springcloud.projo.Dept;
import com.xwli.springcloud.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author xwli
 * @date: 2021/9/6 20:55
 * @desc  提供RestFul服务
 * @since JDK 1.8
 */

@RestController
public class DeptController {

    @Autowired
    private DeptService deptService;

    @GetMapping("/dept/get/{deptNo}")
    public Dept getDeptByDeptNo(@PathVariable("deptNo") Long deptNo,
                                @RequestHeader(name = "Name",required = false)String name){
        System.out.println("RequestHeader==>Name:"+name);
        return deptService.getDeptByDeptNo(deptNo);
    }

    @GetMapping("/dept/list")
    public List<Dept> getDeptAll(){
        return deptService.getDeptAll();
    }
}

